<!doctype html>
<html>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<title>11_Convolutional Neural Network part1</title><link href='https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext' rel='stylesheet' type='text/css' /><style type='text/css'>html {overflow-x: initial !important;}:root { --bg-color:#ffffff; --text-color:#333333; --select-text-bg-color:#B5D6FC; --select-text-font-color:auto; --monospace:"Lucida Console",Consolas,"Courier",monospace; }
html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-size: 1rem; line-height: 1.42857; overflow-x: hidden; background: inherit; tab-size: 4; }
iframe { margin: auto; }
a.url { word-break: break-all; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { text-shadow: none; background: var(--select-text-bg-color); color: var(--select-text-font-color); }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; overflow-wrap: break-word; position: relative; white-space: normal; overflow-x: visible; padding-top: 40px; }
#write.first-line-indent p { text-indent: 2em; }
#write.first-line-indent li p, #write.first-line-indent p * { text-indent: 0px; }
#write.first-line-indent li { margin-left: 2em; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export .footnote-line, .typora-export li, .typora-export p { white-space: pre-wrap; }
@media screen and (max-width: 500px) {
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  #write { padding-left: 20px; padding-right: 20px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
#write li > figure:last-child { margin-bottom: 0.5rem; }
#write ol, #write ul { position: relative; }
img { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { color: inherit; font: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
*, ::after, ::before { box-sizing: border-box; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; }
p { line-height: inherit; }
h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 2; }
p { orphans: 4; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
.md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }
a { cursor: pointer; }
sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.7); color: rgb(85, 85, 85); border-radius: 4px; cursor: pointer; }
sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; }
figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; }
figure > table { margin: 0px !important; }
tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }
table.md-table td { min-width: 32px; }
.CodeMirror-gutters { border-right: 0px; background-color: inherit; }
.CodeMirror-linenumber { user-select: none; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
#write pre { white-space: pre-wrap; }
#write.fences-no-line-wrapping pre { white-space: pre; }
#write pre.ty-contain-cm { white-space: normal; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background: inherit; position: relative !important; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
#write .md-fences.mock-cm { white-space: pre-wrap; }
.md-fences.md-fences-with-lineno { padding-left: 0px; }
#write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; }
.md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; }
.CodeMirror-line, twitterwidget { break-inside: avoid; }
.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }
.footnotes + .footnotes { margin-top: 0px; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background: 0px 0px; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li .mathjax-block, li p { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child, li > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }
#write .footnote-line { white-space: pre-wrap; }
@media print {
  body, html { border: 1px solid transparent; height: 99%; break-after: avoid; break-before: avoid; }
  #write { margin-top: 0px; padding-top: 0px; border-color: transparent !important; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  html.blink-to-pdf { font-size: 13px; }
  .typora-export #write { padding-left: 32px; padding-right: 32px; padding-bottom: 0px; break-after: avoid; }
  .typora-export #write::after { height: 0px; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background: rgb(204, 204, 204); display: block; overflow-x: hidden; }
p > .md-image:only-child:not(.md-img-error) img, p > img:only-child { display: block; margin: auto; }
p > .md-image:only-child { display: inline-block; width: 100%; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.md-math-block { width: 100%; }
.md-math-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: 0px; box-shadow: none; }
.md-task-list-item { position: relative; list-style-type: none; }
.task-list-item.md-task-list-item { padding-left: 0px; }
.md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); border: none; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc-content::after, .md-toc::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); }
.md-toc-item a { text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) {
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
code, pre, samp, tt { font-family: var(--monospace); }
kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: var(--monospace); }
code { text-align: left; vertical-align: initial; }
a.md-print-anchor { white-space: pre !important; border-width: initial !important; border-style: none !important; border-color: initial !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; background: 0px 0px !important; text-decoration: initial !important; text-shadow: initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.html-for-mac .inline-math-svg .MathJax_SVG { vertical-align: 0.2px; }
.md-math-block .MathJax_SVG_Display { text-align: center; margin: 0px; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; overflow-y: hidden; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: var(--monospace); }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: 400; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { transition: none 0s ease 0s; }
.MathJax_SVG_Display svg { vertical-align: middle !important; margin-bottom: 0px !important; margin-top: 0px !important; }
.os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; }
.md-diagram-panel > svg { max-width: 100%; }
[lang="mermaid"] svg, [lang="flow"] svg { max-width: 100%; height: auto; }
[lang="mermaid"] .node text { font-size: 1rem; }
table tr th { border-bottom: 0px; }
video { max-width: 100%; display: block; margin: 0px auto; }
iframe { max-width: 100%; width: 100%; border: none; }
.highlight td, .highlight tr { border: 0px; }
svg[id^="mermaidChart"] { line-height: 1em; }
mark { background: rgb(255, 255, 0); color: rgb(0, 0, 0); }
.md-html-inline .md-plain, .md-html-inline strong, mark .md-inline-math, mark strong { color: inherit; }
mark .md-meta { color: rgb(0, 0, 0); opacity: 0.3 !important; }


.CodeMirror { height: auto; }
.CodeMirror.cm-s-inner { background: inherit; }
.CodeMirror-scroll { overflow: auto hidden; z-index: 3; }
.CodeMirror-gutter-filler, .CodeMirror-scrollbar-filler { background-color: rgb(255, 255, 255); }
.CodeMirror-gutters { border-right: 1px solid rgb(221, 221, 221); background: inherit; white-space: nowrap; }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: rgb(0, 0, 0); }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-property { color: rgb(0, 0, 0); }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: rgb(0, 0, 255); }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: 700; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: red; }
.cm-invalidchar { color: red; }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background: inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { height: 100%; outline: 0px; position: relative; box-sizing: content-box; background: inherit; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-gutter-filler, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-vscrollbar { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow: hidden; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow: hidden; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: 0px 0px !important; border: none !important; }
.CodeMirror-gutter-background { position: absolute; top: 0px; bottom: 0px; z-index: 4; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-radius: 0px; border-width: 0px; background: 0px 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; overflow-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; }
.CodeMirror-wrap pre { overflow-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right: 30px solid transparent; width: fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.cm-searching { background: rgba(255, 255, 0, 0.4); }
@media print {
  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}


:root {
    --side-bar-bg-color: #fafafa;
    --control-text-color: #777;
}

@include-when-export url(https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext);

html {
    font-size: 16px;
}

body {
    font-family: "Open Sans","Clear Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
    color: rgb(51, 51, 51);
    line-height: 1.6;
}

#write {
    max-width: 860px;
  	margin: 0 auto;
  	padding: 30px;
    padding-bottom: 100px;
}
#write > ul:first-child,
#write > ol:first-child{
    margin-top: 30px;
}

a {
    color: #4183C4;
}
h1,
h2,
h3,
h4,
h5,
h6 {
    position: relative;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-weight: bold;
    line-height: 1.4;
    cursor: text;
}
h1:hover a.anchor,
h2:hover a.anchor,
h3:hover a.anchor,
h4:hover a.anchor,
h5:hover a.anchor,
h6:hover a.anchor {
    text-decoration: none;
}
h1 tt,
h1 code {
    font-size: inherit;
}
h2 tt,
h2 code {
    font-size: inherit;
}
h3 tt,
h3 code {
    font-size: inherit;
}
h4 tt,
h4 code {
    font-size: inherit;
}
h5 tt,
h5 code {
    font-size: inherit;
}
h6 tt,
h6 code {
    font-size: inherit;
}
h1 {
    padding-bottom: .3em;
    font-size: 2.25em;
    line-height: 1.2;
    border-bottom: 1px solid #eee;
}
h2 {
   padding-bottom: .3em;
    font-size: 1.75em;
    line-height: 1.225;
    border-bottom: 1px solid #eee;
}
h3 {
    font-size: 1.5em;
    line-height: 1.43;
}
h4 {
    font-size: 1.25em;
}
h5 {
    font-size: 1em;
}
h6 {
   font-size: 1em;
    color: #777;
}
p,
blockquote,
ul,
ol,
dl,
table{
    margin: 0.8em 0;
}
li>ol,
li>ul {
    margin: 0 0;
}
hr {
    height: 2px;
    padding: 0;
    margin: 16px 0;
    background-color: #e7e7e7;
    border: 0 none;
    overflow: hidden;
    box-sizing: content-box;
}

li p.first {
    display: inline-block;
}
ul,
ol {
    padding-left: 30px;
}
ul:first-child,
ol:first-child {
    margin-top: 0;
}
ul:last-child,
ol:last-child {
    margin-bottom: 0;
}
blockquote {
    border-left: 4px solid #dfe2e5;
    padding: 0 15px;
    color: #777777;
}
blockquote blockquote {
    padding-right: 0;
}
table {
    padding: 0;
    word-break: initial;
}
table tr {
    border-top: 1px solid #dfe2e5;
    margin: 0;
    padding: 0;
}
table tr:nth-child(2n),
thead {
    background-color: #f8f8f8;
}
table tr th {
    font-weight: bold;
    border: 1px solid #dfe2e5;
    border-bottom: 0;
    margin: 0;
    padding: 6px 13px;
}
table tr td {
    border: 1px solid #dfe2e5;
    margin: 0;
    padding: 6px 13px;
}
table tr th:first-child,
table tr td:first-child {
    margin-top: 0;
}
table tr th:last-child,
table tr td:last-child {
    margin-bottom: 0;
}

.CodeMirror-lines {
    padding-left: 4px;
}

.code-tooltip {
    box-shadow: 0 1px 1px 0 rgba(0,28,36,.3);
    border-top: 1px solid #eef2f2;
}

.md-fences,
code,
tt {
    border: 1px solid #e7eaed;
    background-color: #f8f8f8;
    border-radius: 3px;
    padding: 0;
    padding: 2px 4px 0px 4px;
    font-size: 0.9em;
}

code {
    background-color: #f3f4f4;
    padding: 0 2px 0 2px;
}

.md-fences {
    margin-bottom: 15px;
    margin-top: 15px;
    padding-top: 8px;
    padding-bottom: 6px;
}


.md-task-list-item > input {
  margin-left: -1.3em;
}

@media print {
    html {
        font-size: 13px;
    }
    table,
    pre {
        page-break-inside: avoid;
    }
    pre {
        word-wrap: break-word;
    }
}

.md-fences {
	background-color: #f8f8f8;
}
#write pre.md-meta-block {
	padding: 1rem;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f7f7f7;
    border: 0;
    border-radius: 3px;
    color: #777777;
    margin-top: 0 !important;
}

.mathjax-block>.code-tooltip {
	bottom: .375rem;
}

.md-mathjax-midline {
    background: #fafafa;
}

#write>h3.md-focus:before{
	left: -1.5625rem;
	top: .375rem;
}
#write>h4.md-focus:before{
	left: -1.5625rem;
	top: .285714286rem;
}
#write>h5.md-focus:before{
	left: -1.5625rem;
	top: .285714286rem;
}
#write>h6.md-focus:before{
	left: -1.5625rem;
	top: .285714286rem;
}
.md-image>.md-meta {
    /*border: 1px solid #ddd;*/
    border-radius: 3px;
    padding: 2px 0px 0px 4px;
    font-size: 0.9em;
    color: inherit;
}

.md-tag {
    color: #a7a7a7;
    opacity: 1;
}

.md-toc { 
    margin-top:20px;
    padding-bottom:20px;
}

.sidebar-tabs {
    border-bottom: none;
}

#typora-quick-open {
    border: 1px solid #ddd;
    background-color: #f8f8f8;
}

#typora-quick-open-item {
    background-color: #FAFAFA;
    border-color: #FEFEFE #e5e5e5 #e5e5e5 #eee;
    border-style: solid;
    border-width: 1px;
}

/** focus mode */
.on-focus-mode blockquote {
    border-left-color: rgba(85, 85, 85, 0.12);
}

header, .context-menu, .megamenu-content, footer{
    font-family: "Segoe UI", "Arial", sans-serif;
}

.file-node-content:hover .file-node-icon,
.file-node-content:hover .file-node-open-state{
    visibility: visible;
}

.mac-seamless-mode #typora-sidebar {
    background-color: #fafafa;
    background-color: var(--side-bar-bg-color);
}

.md-lang {
    color: #b4654d;
}

.html-for-mac .context-menu {
    --item-hover-bg-color: #E6F0FE;
}

#md-notification .btn {
    border: 0;
}

.dropdown-menu .divider {
    border-color: #e5e5e5;
}

.ty-preferences .window-content {
    background-color: #fafafa;
}

.ty-preferences .nav-group-item.active {
    color: white;
    background: #999;
}


</style>
</head>
<body class='typora-export' >
<div  id='write'  class = 'is-node'><h1><a name="-convolutional-neural-networkpart-1" class="md-header-anchor"></a><span>Convolutional Neural network(part 1)</span></h1><blockquote><p><span>CNN常常被用在影像处理上，它的theory base就是三个property，和两个架构</span>
<span>convolution 架构：针对property 1和property 2</span>
<span>max pooling架构：针对property 3</span></p></blockquote><h4><a name="why-cnn-for-image" class="md-header-anchor"></a><span>Why CNN for Image？</span></h4><h5><a name="cnn-vs-dnn" class="md-header-anchor"></a><span>CNN V.s. DNN</span></h5><p><span>我们当然可以用一般的neural network来做影像处理，不一定要用CNN，比如说，你想要做图像的分类，那你就去train一个neural network，它的input是一张图片，你就用里面的pixel来表示这张图片，也就是一个很长很长的vector，而output则是由图像类别组成的vector，假设你有1000个类别，那output就有1000个dimension</span></p><p><span>但是，我们现在会遇到的问题是这样子：实际上，在train neural network的时候，我们会有一种期待说，在这个network structure里面的每一个neuron，都应该代表了一个最基本的classifier；事实上，在文献上，根据训练的结果，也有很多人得到这样的结论，举例来说，下图中：</span></p><ul><li><span>第一个layer的neuron，它就是最简单的classifier，它做的事情就是detect有没有绿色出现、有没有黄色出现、有没有斜的条纹出现等等</span></li><li><span>那第二个layer，它做的事情是detect更复杂的东西，根据第一个layer的output，它如果看到直线横线，就是窗框的一部分；如果看到棕色的直条纹就是木纹；看到斜条纹加灰色的，这个有可能是很多东西，比如说，轮胎的一部分等等</span></li><li><span>再根据第二个hidden layer的output，第三个hidden layer会做更复杂的事情，比如它可以知道说，当某一个neuron看到蜂巢，它就会被activate；当某一个neuron看到车子，它就会被activate；当某一个neuron看到人的上半身，它就会被activate等等</span></li></ul><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/neuron-classifier.png" width="60%;"></center><p><span>那现在的问题是这样子：</span><strong><span>当我们直接用一般的fully connected的feedforward network来做图像处理的时候，往往会需要太多的参数</span></strong></p><p><span>举例来说，假设这是一张100</span><span>*</span><span>100的彩色图片，它的分辨率才100</span><span>*</span><span>100，那这已经是很小张的image了，然后你需要把它拉成一个vector，总共有100</span><span>*</span><span>100</span><span>*</span><span>3个pixel(如果是彩色的图的话，每个pixel其实需要3个value，即RGB值来描述它的)，把这些加起来input vectot就已经有三万维了；如果input vector是三万维，又假设hidden layer有1000个neuron，那仅仅是第一层hidden layer的参数就已经有30000</span><span>*</span><span>1000个了，这样就太多了</span></p><p><span>所以，</span><strong><span>CNN做的事情其实是，来简化这个neural network的架构，我们根据自己的知识和对图像处理的理解，一开始就把某些实际上用不到的参数给过滤掉</span></strong><span>，我们一开始就想一些办法，不要用fully connected network，而是用比较少的参数，来做图像处理这件事情，所以CNN其实是比一般的DNN还要更简单的</span></p><p><span>虽然CNN看起来，它的运作比较复杂，但事实上，它的模型比DNN还要更简单，我们就是用prior knowledge，去把原来fully connected的layer里面的一些参数拿掉，就变成CNN</span></p><h5><a name="three-property-for-cnn-theory-base" class="md-header-anchor"></a><span>Three Property for CNN theory base</span></h5><p><span>为什么我们有可能把一些参数拿掉？为什么我们有可能只用比较少的参数就可以来做图像处理这件事情？下面列出三个对影像处理的观察：(</span><strong><span>这也是CNN架构提出的基础所在！！！</span></strong><span>)</span></p><h6><a name="some-patterns-are-much-smaller-than-the-whole-image" class="md-header-anchor"></a><span>Some patterns are much smaller than the whole image</span></h6><p><span>在影像处理里面，如果在network的第一层hidden layer里，那些neuron要做的事情是侦测有没有一种东西、一种pattern(图案样式)出现，那大部分的pattern其实是比整张image要小的，所以对一个neuron来说，想要侦测有没有某一个pattern出现，它其实并不需要看整张image，只需要看这张image的一小部分，就可以决定这件事情了</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/pattern.png" width="60%;"></center><p><span>举例来说，假设现在我们有一张鸟的图片，那第一层hidden layer的某一个neuron的工作是，检测有没有鸟嘴的存在(你可能还有一些neuron侦测有没有鸟嘴的存在、有一些neuron侦测有没有爪子的存在、有一些neuron侦测有没有翅膀的存在、有没有尾巴的存在，之后合起来，就可以侦测，图片中有没有一只鸟)，那它其实并不需要看整张图，因为，其实我们只要给neuron看这个小的红色杠杠里面的区域，它其实就可以知道说，这是不是一个鸟嘴，对人来说也是一样，只要看这个小的区域你就会知道说这是鸟嘴，所以，</span><strong><span>每一个neuron其实只要连接到一个小块的区域就好，它不需要连接到整张完整的图，因此也对应着更少的参数</span></strong></p><h6><a name="the-same-patterns-appear-in-different-regions" class="md-header-anchor"></a><span>The same patterns appear in different regions</span></h6><p><span>同样的pattern，可能会出现在image的不同部分，但是它们有同样的形状、代表的是同样的含义，因此它们也可以用同样的neuron、同样的参数，被同一个detector检测出来</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/pattern-region.png" width="60%;"></center><p><span>举例来说，上图中分别有一个处于左上角的鸟嘴和一个处于中央的鸟嘴，但你并不需要训练两个不同的detector去专门侦测左上角有没有鸟嘴和中央有没有鸟嘴这两件事情，这样做太冗余了，我们要cost down(降低成本)，我们并不需要有两个neuron、两组不同的参数来做duplicate(重复一样)的事情，所以</span><strong><span>我们可以要求这些功能几乎一致的neuron共用一组参数，它们share同一组参数就可以帮助减少总参数的量</span></strong></p><h6><a name="subsampling-the-pixels-will-not-change-the-object" class="md-header-anchor"></a><span>Subsampling the pixels will not change the object</span></h6><p><span>我们可以对一张image做subsampling(二次抽样)，假如你把它奇数行、偶数列的pixel拿掉，image就可以变成原来的十分之一大小，而且并不会影响人对这张image的理解，对你来说，下面两张大小不一的image看起来不会有什么太大的区别，你都可以识别里面有什么物件，因此subsampling对图像辨识来说，可能是没有太大的影响的</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/subsamp.png" width="60%;"></center><p><span>所以，</span><strong><span>我们可以利用subsampling这个概念把image变小，从而减少需要用到的参数量</span></strong></p><h4><a name="the-whole-cnn-structure" class="md-header-anchor"></a><span>The whole CNN structure</span></h4><p><span>整个CNN的架构是这样的：</span></p><p><span>首先，input一张image以后，它会先通过Convolution的layer，接下来做Max Pooling这件事，然后再去做Convolution，再做Maxi Pooling...，这个process可以反复进行多次(重复次数需要事先决定)，这就是network的架构，就好像network有几层一样，你要做几次convolution，做几次Max Pooling，在定这个network的架构时就要事先决定好</span></p><p><span>当你做完先前决定的convolution和max pooling的次数后，你要做的事情是Flatten，做完flatten以后，你就把Flatten output丢到一般的Fully connected network里面去，最终得到影像辨识的结果</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/whole-cnn.png" width="60%;"></center><p><span>我们基于之前提到的三个对影像处理的观察，设计了CNN这样的架构，第一个是要侦测一个pattern，你不需要看整张image，只要看image的一个小部分；第二个是同样的pattern会出现在一张图片的不同区域；第三个是我们可以对整张image做subsampling</span></p><p><span>那</span><strong><span>前面这两个property，是用convolution的layer来处理的；最后这个property，是用max pooling来处理的</span></strong></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/property.png" width="60%;"></center><h4><a name="convolution" class="md-header-anchor"></a><span>Convolution</span></h4><p><span>假设现在我们network的input是一张6</span><span>*</span><span>6的image，图像是黑白的，因此每个pixel只需要用一个value来表示，而在convolution layer里面，有一堆Filter，这边的每一个Filter，其实就等同于是Fully connected layer里的一个neuron</span></p><h5><a name="property-1" class="md-header-anchor"></a><span>Property 1</span></h5><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/filter.png" width="60%;"></center><p><span>每一个Filter其实就是一个matrix，这个matrix里面每一个element的值，就跟那些neuron的weight和bias一样，是network的parameter，它们具体的值都是通过Training data学出来的，而不是人去设计的</span></p><p><span>所以，每个Filter里面的值是什么，要做什么事情，都是自动学习出来的，上图中每一个filter是3</span><span>*</span><span>3的size，意味着它就是在侦测一个3</span><span>*</span><span>3的pattern，</span><strong><span>当它侦测的时候，并不会去看整张image，它只看一个3</span><span>*</span><span>3范围内的pixel，就可以判断某一个pattern有没有出现，这就考虑了property 1</span></strong></p><h5><a name="property-2" class="md-header-anchor"></a><span>Property 2</span></h5><p><span>这个filter是从image的左上角开始，做一个slide window，每次向右挪动一定的距离，这个距离就叫做stride，由你自己设定，每次filter停下的时候就跟image中对应的3</span><span>*</span><span>3的matrix做一个内积(相同位置的值相乘并累计求和)，这里假设stride=1，那么我们的filter每次移动一格，当它碰到image最右边的时候，就从下一行的最左边开始重复进行上述操作，经过一整个convolution的process，最终得到下图所示的红色的4</span><span>*</span><span>4 matrix</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/filter1.png" width="60%;"></center><p><span>观察上图中的Filter1，它斜对角的地方是1,1,1，所以它的工作就是detect有没有连续的从左上角到右下角的1,1,1出现在这个image里面，检测到的结果已在上图中用蓝线标识出来，此时filter得到的卷积结果的左上和左下得到了最大的值，这就代表说，该filter所要侦测的pattern出现在image的左上角和左下角</span></p><p><strong><span>同一个pattern出现在image左上角的位置和左下角的位置，并不需要用到不同的filter，我们用filter1就可以侦测出来，这就考虑了property 2</span></strong></p><h5><a name="feature-map" class="md-header-anchor"></a><span>Feature Map</span></h5><p><span>在一个convolution的layer里面，它会有一打filter，不一样的filter会有不一样的参数，但是这些filter做卷积的过程都是一模一样的，你把filter2跟image做完convolution以后，你就会得到另外一个蓝色的4</span><span>*</span><span>4 matrix，那这个蓝色的4</span><span>*</span><span>4 matrix跟之前红色的4</span><span>*</span><span>4matrix合起来，就叫做</span><strong><span>Feature Map(特征映射)</span></strong><span>，有多少个filter，对应就有多少个映射后的image</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/filter2.png" width="60%;"></center><p><span>CNN对</span><strong><span>不同scale的相同pattern的处理</span></strong><span>上存在一定的困难，由于现在每一个filter size都是一样的，这意味着，如果你今天有同一个pattern，它有不同的size，有大的鸟嘴，也有小的鸟嘴，CNN并不能够自动处理这个问题；DeepMind曾经发过一篇paper，上面提到了当你input一张image的时候，它在CNN前面，再接另外一个network，这个network做的事情是，它会output一些scalar，告诉你说，它要把这个image的里面的哪些位置做旋转、缩放，然后，再丢到CNN里面，这样你其实会得到比较好的performance</span></p><h4><a name="colorful-image" class="md-header-anchor"></a><span>Colorful image</span></h4><p><span>刚才举的例子是黑白的image，所以你input的是一个matrix，如果今天是彩色的image会怎么样呢？我们知道彩色的image就是由RGB组成的，所以一个彩色的image，它就是好几个matrix叠在一起，是一个立方体，如果我今天要处理彩色的image，要怎么做呢？</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/rgb.png" width="60%;"></center><p><span>这个时候你的filter就不再是一个matrix了，它也会是一个立方体，如果你今天是RGB这三个颜色来表示一个pixel的话，那你的input就是3</span><span>*</span><span>6</span><span>*</span><span>6，你的filter就是3</span><span>*</span><span>3</span><span>*</span><span>3，你的filter的高就是3，你在做convolution的时候，就是把这个filter的9个值跟这个image里面的9个值做内积，可以想象成filter的每一层都分别跟image的三层做内积，得到的也是一个三层的output，每一个filter同时就考虑了不同颜色所代表的channel</span></p><h4><a name="convolution-vs-fully-connected" class="md-header-anchor"></a><span>Convolution V.s. Fully connected</span></h4><h5><a name="filter是特殊的neuron" class="md-header-anchor"></a><span>filter是特殊的”neuron“</span></h5><p><span>接下来要讲的是，convolution跟fully connected有什么关系，你可能觉得说，它是一个很特别的operation，感觉跟neural network没半毛钱关系，其实，它就是一个neural network</span></p><p><span>convolution这件事情，其实就是fully connected的layer把一些weight拿掉而已，下图中绿色方框标识出的feature map的output，其实就是hidden layer的neuron的output</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/convolution-fully.png" width="60%;"></center><p><span>接下来我们来解释这件事情：</span></p><p><span>如下图所示，我们在做convolution的时候，把filter放在image的左上角，然后再去做inner product，得到一个值3；这件事情等同于，我们现在把这个image的6</span><span>*</span><span>6的matrix拉直变成右边这个用于input的vector，然后，你有一个红色的neuron，这些input经过这个neuron之后，得到的output是3</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/filter-neuron1.png" width="60%;"></center><h5><a name="每个neuron只检测image的部分区域" class="md-header-anchor"></a><span>每个“neuron”只检测image的部分区域</span></h5><p><span>那这个neuron的output怎么来的呢？这个neuron实际上就是由filter转化而来的，我们把filter放在image的左上角，此时filter考虑的就是和它重合的9个pixel，假设你把这一个6</span><span>*</span><span>6的image的36个pixel拉成直的vector作为input，那这9个pixel分别就对应着右侧编号1，2，3的pixel，编号7，8，9的pixel跟编号13，14，15的pixel</span></p><p><span>如果我们说这个filter和image matrix做inner product以后得到的output 3，就是input vector经过某个neuron得到的output 3的话，这就代表说存在这样一个neuron，这个neuron带weight的连线，就只连接到编号为1，2，3，7，8，9，13，14，15的这9个pixel而已，而这个neuron和这9个pixel连线上所标注的的weight就是filter matrix里面的这9个数值</span></p><p><span>作为对比，Fully connected的neuron是必须连接到所有36个input上的，但是，我们现在只用连接9个input，因为我们知道要detect一个pattern，不需要看整张image，看9个input pixel就够了，所以当我们这么做的时候，就用了比较少的参数</span></p><h5><a name="neuron之间共享参数" class="md-header-anchor"></a><span>“neuron”之间共享参数</span></h5><p><span>当我们把filter做stride = 1的移动的时候，会发生什么事呢？此时我们通过filter和image matrix的内积得到另外一个output值-1，我们假设这个-1是另外一个neuron的output，那这个neuron会连接到哪些input呢？下图中这个框起来的地方正好就对应到pixel 2，3，4，pixel 8，9，10跟pixel 14，15，16</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/share-weight.png" width="60%;"></center><p><span>你会发现output为3和-1的这两个neuron，它们分别去检测在image的两个不同位置上是否存在某个pattern，因此在Fully connected layer里它们做的是两件不同的事情，每一个neuron应该有自己独立的weight</span></p><p><span>但是，当我们做这个convolution的时候，首先我们把每一个neuron前面连接的weight减少了，然后我们强迫某些neuron(比如上图中output为3和-1的两个neuron)，它们一定要共享一组weight，虽然这两个neuron连接到的pixel对象各不相同，但它们用的weight都必须是一样的，等于filter里面的元素值，这件事情就叫做weight share，当我们做这件事情的时候，用的参数，又会比原来更少</span></p><h5><a name="总结" class="md-header-anchor"></a><span>总结</span></h5><p><span>因此我们可以这样想，有这样一些特殊的neuron，它们只连接着9条带weight的线(9=3</span><span>*</span><span>3对应着filter的元素个数，这些weight也就是filter内部的元素值，上图中圆圈的颜色与连线的颜色一一对应)</span></p><p><span>当filter在image matrix上移动做convolution的时候，每次移动做的事情实际上是去检测这个地方有没有某一种pattern，对于Fully connected layer来说，它是对整张image做detection的，因此每次去检测image上不同地方有没有pattern其实是不同的事情，所以这些neuron都必须连接到整张image的所有pixel上，并且不同neuron的连线上的weight都是相互独立的</span></p><p><mark><strong><span>那对于convolution layer来说，首先它是对image的一部分做detection的，因此它的neuron只需要连接到image的部分pixel上，对应连线所需要的weight参数就会减少；其次由于是用同一个filter去检测不同位置的pattern，所以这对convolution layer来说，其实是同一件事情，因此不同的neuron，虽然连接到的pixel对象各不相同，但是在“做同一件事情”的前提下，也就是用同一个filter的前提下，这些neuron所使用的weight参数都是相同的，通过这样一张weight share的方式，再次减少network所需要用到的weight参数</span></strong></mark></p><p><span>CNN的本质，就是减少参数的过程</span></p><h5><a name="补充" class="md-header-anchor"></a><span>补充</span></h5><p><span>看到这里你可能会问，这样的network该怎么搭建，又该怎么去train呢？</span></p><p><span>首先，第一件事情就是这都是用toolkit做的，所以你大概不会自己去写；如果你要自己写的话，它其实就是跟原来的Backpropagation用一模一样的做法，只是有一些weight就永远是0，你就不去train它，它就永远是0</span></p><p><span>然后，怎么让某些neuron的weight值永远都是一样呢？你就用一般的Backpropagation的方法，对每个weight都去算出gradient，再把本来要tight在一起、要share weight的那些weight的gradient平均，然后，让他们update同样值就ok了</span></p><h4><a name="max-pooling" class="md-header-anchor"></a><span>Max Pooling</span></h4><h5><a name="operation-of-max-pooling" class="md-header-anchor"></a><span>Operation of max pooling</span></h5><p><span>相较于convolution，max pooling是比较简单的，它就是做subsampling，根据filter 1，我们得到一个4</span><span>*</span><span>4的matrix，根据filter 2，你得到另外一个4</span><span>*</span><span>4的matrix，接下来，我们要做什么事呢？</span></p><p><span>我们把output四个分为一组，每一组里面通过选取平均值或最大值的方式，把原来4个value合成一个 value，这件事情相当于在image每相邻的四块区域内都挑出一块来检测，这种subsampling的方式就可以让你的image缩小！</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/max-pooling.png" width="60%;"></center><p><span>讲到这里你可能会有一个问题，如果取Maximum放到network里面，不就没法微分了吗？max这个东西，感觉是没有办法对它微分的啊，其实是可以的，后面的章节会讲到Maxout network，会告诉你怎么用微分的方式来处理它</span></p><h5><a name="convolution--max-pooling" class="md-header-anchor"></a><span>Convolution + Max Pooling</span></h5><p><span>所以，结论是这样的：</span></p><p><span>做完一次convolution加一次max pooling，我们就把原来6</span><span>*</span><span>6的image，变成了一个2</span><span>*</span><span>2的image；至于这个2</span><span>*</span><span>2的image，它每一个pixel的深度，也就是每一个pixel用几个value来表示，就取决于你有几个filter，如果你有50个filter，就是50维，像下图中是两个filter，对应的深度就是两维</span></p><p><span>所以，这是一个新的比较小的image，它表示的是不同区域上提取到的特征，实际上不同的filter检测的是该image同一区域上的不同特征属性，所以每一层channel(通道)代表的是一种属性，一块区域有几种不同的属性，就有几层不同的channel，对应的就会有几个不同的filter对其进行convolution操作</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/max-pool.png" width="60%;"></center><p><span>这件事情可以repeat很多次，你可以把得到的这个比较小的image，再次进行convolution和max pooling的操作，得到一个更小的image，依次类推</span></p><p><span>有这样一个问题：假设我第一个convolution有25个filter，通过这些filter得到25个feature map，然后repeat的时候第二个convolution也有25个filter，那这样做完，我是不是会得到25^2个feature map？</span></p><p><span>其实不是这样的，你这边做完一次convolution，得到25个feature map之后再做一次convolution，还是会得到25个feature map，因为convolution在考虑input的时候，是会考虑深度的，它并不是每一个channel分开考虑，而是一次考虑所有的channel，所以，你convolution这边有多少个filter，再次output的时候就会有多少个channel</span></p><p><span>因此你这边有25个channel，经过含有25个filter的convolution之后output还会是25个channel，只是这边的每一个channel，它都是一个cubic(立方体)，它的高有25个value那么高</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/channel.png" width="60%;"></center><h4><a name="flatten" class="md-header-anchor"></a><span>Flatten</span></h4><p><span>做完convolution和max pooling之后，就是FLatten和Fully connected Feedforward network的部分</span></p><p><span>Flatten的意思是，把左边的feature map拉直，然后把它丢进一个Fully connected Feedforward network，然后就结束了，也就是说，我们之前通过CNN提取出了image的feature，它相较于原先一整个image的vetor，少了很大一部分内容，因此需要的参数也大幅度地减少了，但最终，也还是要丢到一个Fully connected的network中去做最后的分类工作</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/fatten.png" width="50%;"></center><h4><a name="cnn-in-keras" class="md-header-anchor"></a><span>CNN in Keras</span></h4><h5><a name="内容简介" class="md-header-anchor"></a><span>内容简介</span></h5><p><span>接下来就讲一下，如何用Keras来implement CNN，实际上在compile、training和fitting的部分，内容跟DNN是一模一样的，对CNN来说，唯一需要改变的是network structure，以及input的format</span></p><p><span>本来在DNN里，input是一个由image拉直展开而成的vector，但现在如果是CNN的话，它是会考虑input image的几何空间的，所以不能直接input一个vector，而是要input一个tensor给它(tensor就是高维的vector)，这里你要给它一个三维的vector，一个image的长宽各是一维，如果它是彩色的话，RGB就是第三维，所以你要assign一个三维的matrix，这个高维的matrix就叫做tensor</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/cnn-keras1.png" width="60%;"></center><p><span>那怎么implement一个convolution的layer呢？</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="python"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="python"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">model2</span>.<span class="cm-property">add</span>( <span class="cm-variable">Convolution2D</span>(<span class="cm-number">25</span>,<span class="cm-number">3</span>,<span class="cm-number">3</span>, <span class="cm-variable">input_shape</span>=(<span class="cm-number">28</span>,<span class="cm-number">28</span>,<span class="cm-number">1</span>)) )</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 23px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><span>还是用</span><code>model.add</code><span>增加CNN的layer，将原先的Dense改成Convolution2D，参数25代表你有25个filter，参数3,3代表你的filter都是3</span><span>*</span><span>3的matrix，此外你还需要告诉model，你input的image的shape是什么样子的，假设我现在要做手写数字识别，input就是28</span><span>*</span><span>28的image，又因为它的每一个pixel都只有单一颜色，因此</span><code>input_shape</code><span>的值就是(28,28,1)，如果是RGB的话，1就要改成3</span></p><p><span>然后增加一层Max Pooling的layer</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="python"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="python"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">model2</span>.<span class="cm-property">add</span>( <span class="cm-variable">MaxPooling2D</span>(<span class="cm-number">2</span>,<span class="cm-number">2</span>) )</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 23px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><span>这里参数(2,2)指的是，我们把通过convolution得到的feature map，按照2</span><span>*</span><span>2的方式分割成一个个区域，每次选取最大的那个值，并将这些值组成一个新的比较小的image，作为subsampling的结果</span></p><h5><a name="过程描述" class="md-header-anchor"></a><span>过程描述</span></h5><ul><li><span>假设我们input是一个1</span><span>*</span><span>28</span><span>*</span><span>28的image</span></li><li><span>通过25个filter的convolution layer以后你得到的output，会有25个channel，又因为filter的size是3</span><span>*</span><span>3，因此如果不考虑image边缘处的处理的话，得到的channel会是26</span><span>*</span><span>26的，因此通过第一个convolution得到25</span><span>*</span><span>26</span><span>*</span><span>26的cubic image(这里把这张image想象成长宽为26，高为25的cubic立方体)</span></li><li><span>接下来就是做Max pooling，把2</span><span>*</span><span>2的pixel分为一组，然后从里面选一个最大的组成新的image，大小为25</span><span>*</span><span>13</span><span>*</span><span>13(cubic长宽各被砍掉一半)</span></li><li><span>再做一次convolution，假设这次选择50个filter，每个filter size是3</span><span>*</span><span>3的话，output的channel就变成有50个，那13</span><span>*</span><span>13的image，通过3</span><span>*</span><span>3的filter，就会变成11</span><span>*</span><span>11，因此通过第二个convolution得到50</span><span>*</span><span>11</span><span>*</span><span>11的image(得到一个新的长宽为11，高为50的cubic)</span></li><li><span>再做一次Max Pooling，变成50</span><span>*</span><span>50</span><span>*</span><span>5</span></li></ul><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/cnn-keras3.png" width="60%;"></center><p><span>在第一个convolution里面，每一个filter都有9个参数，它就是一个3</span><span>*</span><span>3的matrix；但是在第二个convolution layer里面，虽然每一个filter都是3</span><span>*</span><span>3，但它其实不是3</span><span>*</span><span>3个参数，因为它的input是一个25</span><span>*</span><span>13</span><span>*</span><span>13的cubic，这个cubic的channel有25个，所以要用同样高度的cubic filter对它进行卷积，于是我们的filter实际上是一个25</span><span>*</span><span>3</span><span>*</span><span>3的cubic，所以这边每个filter共有225个参数</span></p><center><img src="https://gitee.com/Sakura-gh/ML-notes/raw/master/img/cnn-keras2.png" width="60%;"></center><p><span>通过两次convolution和max pooling的组合，最终的image变成了50</span><span>*</span><span>5</span><span>*</span><span>5的size，然后使用Flatten将这个image拉直，变成一个1250维的vector，再把它丢到一个Fully Connected Feedforward network里面，network structure就搭建完成了</span></p><h5><a name="一个重要的问题" class="md-header-anchor"></a><span>一个重要的问题</span></h5><p><span>看到这里，你可能会有一个疑惑，第二次convolution的input是25</span><span>*</span><span>13</span><span>*</span><span>13的cubic，用50个3</span><span>*</span><span>3的filter卷积后，得到的输出时应该是50个cubic，且每个cubic的尺寸为25</span><span>*</span><span>11</span><span>*</span><span>11，那么max pooling把长宽各砍掉一半后就是50层25</span><span>*</span><span>5</span><span>*</span><span>5的cubic，那flatten后不应该就是50</span><span>*</span><span>25</span><span>*</span><span>5</span><span>*</span><span>5吗？</span></p><p><span>其实不是这样的，在第二次做convolution的时候，我们是用25</span><span>*</span><span>3</span><span>*</span><span>3的cubic filter对25</span><span>*</span><span>13</span><span>*</span><span>13的cubic input进行卷积操作的，filter的每一层和input cubic中对应的每一层(也就是每一个channel)，它们进行内积后，还要把cubic的25个channel的内积值进行求和，作为这个“neuron”的output，它是一个scalar，这个cubic filter对整个cubic input做完一遍卷积操作后，得到的是一层scalar，然后有50个cubic filter，对应着50层scalar，因此最终得到的output是一个50</span><span>*</span><span>11</span><span>*</span><span>11的cubic！</span></p><p><span>这里的关键是filter和image都是cubic，每个cubic filter有25层高，它和同样有25层高的cubic image做卷积，并不是单单把每个cubic对应的channel进行内积，还会把这些内积求和！！！最终变为1层，因此</span><mark><strong><span>两个矩阵或者tensor做了卷积后，不管之前的维数如何，都会变为一个scalor！</span></strong></mark><span>，故如果有50个Filter，无论input是什么样子的，最终的output还会是50层</span></p><p>&nbsp;</p><h4><a name="appendixcnn-in-keras20" class="md-header-anchor"></a><span>Appendix：CNN in Keras2.0</span></h4><p><span>这里还是举</span><strong><span>手写数字识别</span></strong><span>的例子，将单纯使用DNN和加上CNN的情况作为对比</span></p><h5><a name="code" class="md-header-anchor"></a><span>code</span></h5><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="python" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="python"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><span><span>​</span>x</span></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">import</span> <span class="cm-variable">numpy</span> <span class="cm-keyword">as</span> <span class="cm-variable">np</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">from</span> <span class="cm-variable">keras</span>.<span class="cm-property">models</span> <span class="cm-keyword">import</span> <span class="cm-variable">Sequential</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">from</span> <span class="cm-variable">keras</span>.<span class="cm-property">layers</span> <span class="cm-keyword">import</span> <span class="cm-variable">Convolution2D</span>, <span class="cm-variable">MaxPooling2D</span>, <span class="cm-variable">Flatten</span>, <span class="cm-variable">Conv2D</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">from</span> <span class="cm-variable">keras</span>.<span class="cm-property">layers</span>.<span class="cm-property">core</span> <span class="cm-keyword">import</span> <span class="cm-variable">Dense</span>, <span class="cm-variable">Dropout</span>, <span class="cm-variable">Activation</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">from</span> <span class="cm-variable">keras</span>.<span class="cm-property">optimizers</span> <span class="cm-keyword">import</span> <span class="cm-variable">SGD</span>, <span class="cm-variable">Adam</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">from</span> <span class="cm-variable">keras</span>.<span class="cm-property">utils</span> <span class="cm-keyword">import</span> <span class="cm-variable">np_utils</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">from</span> <span class="cm-variable">keras</span>.<span class="cm-property">datasets</span> <span class="cm-keyword">import</span> <span class="cm-variable">mnist</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># categorical_crossentropy</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">def</span> <span class="cm-def">load_mnist_data</span>(<span class="cm-variable">number</span>):</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment"># the data, shuffled and  split between train and test sets</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  (<span class="cm-variable">x_train</span>, <span class="cm-variable">y_train</span>), (<span class="cm-variable">x_test</span>, <span class="cm-variable">y_test</span>) = <span class="cm-variable">mnist</span>.<span class="cm-property">load_data</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_train</span> = <span class="cm-variable">x_train</span>[<span class="cm-number">0</span>:<span class="cm-variable">number</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">y_train</span> = <span class="cm-variable">y_train</span>[<span class="cm-number">0</span>:<span class="cm-variable">number</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_train</span> = <span class="cm-variable">x_train</span>.<span class="cm-property">reshape</span>(<span class="cm-variable">number</span>, <span class="cm-number">784</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_test</span> = <span class="cm-variable">x_test</span>.<span class="cm-property">reshape</span>(<span class="cm-number">10000</span>, <span class="cm-number">784</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_train</span> = <span class="cm-variable">x_train</span>.<span class="cm-property">astype</span>(<span class="cm-string">'float32'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_test</span> = <span class="cm-variable">x_test</span>.<span class="cm-property">astype</span>(<span class="cm-string">'float32'</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment"># convert class vectors to binary class matrices</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">y_train</span> = <span class="cm-variable">np_utils</span>.<span class="cm-property">to_categorical</span>(<span class="cm-variable">y_train</span>, <span class="cm-number">10</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">y_test</span> = <span class="cm-variable">np_utils</span>.<span class="cm-property">to_categorical</span>(<span class="cm-variable">y_test</span>, <span class="cm-number">10</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_train</span> = <span class="cm-variable">x_train</span> <span class="cm-operator">/</span> <span class="cm-number">255</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_test</span> = <span class="cm-variable">x_test</span> <span class="cm-operator">/</span> <span class="cm-number">255</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-keyword">return</span> (<span class="cm-variable">x_train</span>, <span class="cm-variable">y_train</span>), (<span class="cm-variable">x_test</span>, <span class="cm-variable">y_test</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">if</span> <span class="cm-variable">__name__</span> == <span class="cm-string">'__main__'</span>:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  (<span class="cm-variable">x_train</span>, <span class="cm-variable">y_train</span>), (<span class="cm-variable">x_test</span>, <span class="cm-variable">y_test</span>) = <span class="cm-variable">load_mnist_data</span>(<span class="cm-number">10000</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment"># do DNN</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span> = <span class="cm-variable">Sequential</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span>.<span class="cm-property">add</span>(<span class="cm-variable">Dense</span>(<span class="cm-variable">input_dim</span>=<span class="cm-number">28</span> <span class="cm-operator">*</span> <span class="cm-number">28</span>, <span class="cm-variable">units</span>=<span class="cm-number">500</span>, <span class="cm-variable">activation</span>=<span class="cm-string">'relu'</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span>.<span class="cm-property">add</span>(<span class="cm-variable">Dense</span>(<span class="cm-variable">units</span>=<span class="cm-number">500</span>, <span class="cm-variable">activation</span>=<span class="cm-string">'relu'</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span>.<span class="cm-property">add</span>(<span class="cm-variable">Dense</span>(<span class="cm-variable">units</span>=<span class="cm-number">500</span>, <span class="cm-variable">activation</span>=<span class="cm-string">'relu'</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span>.<span class="cm-property">add</span>(<span class="cm-variable">Dense</span>(<span class="cm-variable">units</span>=<span class="cm-number">10</span>, <span class="cm-variable">activation</span>=<span class="cm-string">'softmax'</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span>.<span class="cm-property">summary</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span>.<span class="cm-property">compile</span>(<span class="cm-variable">loss</span>=<span class="cm-string">'categorical_crossentropy'</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">optimizer</span>=<span class="cm-string">'adam'</span>, <span class="cm-variable">metrics</span>=[<span class="cm-string">'accuracy'</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model</span>.<span class="cm-property">fit</span>(<span class="cm-variable">x_train</span>, <span class="cm-variable">y_train</span>, <span class="cm-variable">batch_size</span>=<span class="cm-number">100</span>, <span class="cm-variable">epochs</span>=<span class="cm-number">20</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">result_train</span> = <span class="cm-variable">model</span>.<span class="cm-property">evaluate</span>(<span class="cm-variable">x_train</span>, <span class="cm-variable">y_train</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-builtin">print</span>(<span class="cm-string">'\nTrain Acc:\n'</span>, <span class="cm-variable">result_train</span>[<span class="cm-number">1</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">result_test</span> = <span class="cm-variable">model</span>.<span class="cm-property">evaluate</span>(<span class="cm-variable">x_test</span>, <span class="cm-variable">y_test</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-builtin">print</span>(<span class="cm-string">'\nTest Acc:\n'</span>, <span class="cm-variable">result_test</span>[<span class="cm-number">1</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment"># do CNN</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_train</span> = <span class="cm-variable">x_train</span>.<span class="cm-property">reshape</span>(<span class="cm-variable">x_train</span>.<span class="cm-property">shape</span>[<span class="cm-number">0</span>], <span class="cm-number">1</span>, <span class="cm-number">28</span>, <span class="cm-number">28</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">x_test</span> = <span class="cm-variable">x_test</span>.<span class="cm-property">reshape</span>(<span class="cm-variable">x_test</span>.<span class="cm-property">shape</span>[<span class="cm-number">0</span>], <span class="cm-number">1</span>, <span class="cm-number">28</span>, <span class="cm-number">28</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span> = <span class="cm-variable">Sequential</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">add</span>(<span class="cm-variable">Conv2D</span>(<span class="cm-number">25</span>, (<span class="cm-number">3</span>, <span class="cm-number">3</span>), <span class="cm-variable">input_shape</span>=(</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">1</span>, <span class="cm-number">28</span>, <span class="cm-number">28</span>), <span class="cm-variable">data_format</span>=<span class="cm-string">'channels_first'</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">add</span>(<span class="cm-variable">MaxPooling2D</span>((<span class="cm-number">2</span>, <span class="cm-number">2</span>)))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">add</span>(<span class="cm-variable">Conv2D</span>(<span class="cm-number">50</span>, (<span class="cm-number">3</span>, <span class="cm-number">3</span>)))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">add</span>(<span class="cm-variable">MaxPooling2D</span>((<span class="cm-number">2</span>, <span class="cm-number">2</span>)))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">add</span>(<span class="cm-variable">Flatten</span>())</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">add</span>(<span class="cm-variable">Dense</span>(<span class="cm-variable">units</span>=<span class="cm-number">100</span>, <span class="cm-variable">activation</span>=<span class="cm-string">'relu'</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">add</span>(<span class="cm-variable">Dense</span>(<span class="cm-variable">units</span>=<span class="cm-number">10</span>, <span class="cm-variable">activation</span>=<span class="cm-string">'softmax'</span>))</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">summary</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">compile</span>(<span class="cm-variable">loss</span>=<span class="cm-string">'categorical_crossentropy'</span>,</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-variable">optimizer</span>=<span class="cm-string">'adam'</span>, <span class="cm-variable">metrics</span>=[<span class="cm-string">'accuracy'</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">model2</span>.<span class="cm-property">fit</span>(<span class="cm-variable">x_train</span>, <span class="cm-variable">y_train</span>, <span class="cm-variable">batch_size</span>=<span class="cm-number">100</span>, <span class="cm-variable">epochs</span>=<span class="cm-number">20</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">result_train</span> = <span class="cm-variable">model2</span>.<span class="cm-property">evaluate</span>(<span class="cm-variable">x_train</span>, <span class="cm-variable">y_train</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-builtin">print</span>(<span class="cm-string">'\nTrain CNN Acc:\n'</span>, <span class="cm-variable">result_train</span>[<span class="cm-number">1</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">result_test</span> = <span class="cm-variable">model2</span>.<span class="cm-property">evaluate</span>(<span class="cm-variable">x_test</span>, <span class="cm-variable">y_test</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-builtin">print</span>(<span class="cm-string">'\nTest CNN Acc:\n'</span>, <span class="cm-variable">result_test</span>[<span class="cm-number">1</span>])</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1748px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1748px;"></div></div></div></pre><h5><a name="result" class="md-header-anchor"></a><span>result</span></h5><h6><a name="dnn" class="md-header-anchor"></a><span>DNN</span></h6><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="python" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="python"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Using</span> <span class="cm-variable">TensorFlow</span> <span class="cm-variable">backend</span>.</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-property">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Layer</span> (<span class="cm-builtin">type</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-variable">Output</span> <span class="cm-variable">Shape</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">Param</span> <span class="cm-comment"># &nbsp; </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">=================================================================</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">dense_1</span> (<span class="cm-variable">Dense</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">500</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">392500</span> &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">dense_2</span> (<span class="cm-variable">Dense</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">500</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">250500</span> &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">dense_3</span> (<span class="cm-variable">Dense</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">500</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">250500</span> &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">dense_4</span> (<span class="cm-variable">Dense</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">10</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">5010</span> &nbsp; &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">=================================================================</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Total</span> <span class="cm-variable">params</span>: <span class="cm-number">898</span>,<span class="cm-number">510</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Trainable</span> <span class="cm-variable">params</span>: <span class="cm-number">898</span>,<span class="cm-number">510</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Non</span><span class="cm-operator">-</span><span class="cm-variable">trainable</span> <span class="cm-variable">params</span>: <span class="cm-number">0</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">1</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">207</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.4727</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.8643</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">2</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">1</span><span class="cm-variable">s</span> <span class="cm-number">149</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.1613</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9521</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">3</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">159</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0916</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9726</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">4</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">173</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0680</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9769</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">5</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">166</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0437</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9850</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">6</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">166</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0274</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9921</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">7</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">168</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0265</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9892</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">8</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">161</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0240</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9916</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">9</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">169</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0149</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9950</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">10</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">155</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0258</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9933</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">11</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">168</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0206</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9934</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">12</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">161</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0132</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9955</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">13</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">168</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0113</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9964</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">14</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">169</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0027</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9991</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">15</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">157</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">6.6533e-04</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9999</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">16</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">1</span><span class="cm-variable">s</span> <span class="cm-number">150</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">1.1253e-04</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">1.0000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">17</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">152</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">8.3190e-05</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">1.0000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">18</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">174</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">6.7850e-05</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">1.0000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">19</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">173</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">5.6810e-05</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">1.0000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">20</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">2</span><span class="cm-variable">s</span> <span class="cm-number">172</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">4.8757e-05</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">1.0000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">1</span><span class="cm-variable">s</span> <span class="cm-number">97</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Train</span> <span class="cm-variable">Acc</span>: <span class="cm-number">1.0</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">1</span><span class="cm-variable">s</span> <span class="cm-number">77</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Test</span> <span class="cm-variable">Acc</span>: <span class="cm-number">0.9661</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1541px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1541px;"></div></div></div></pre><h6><a name="cnn" class="md-header-anchor"></a><span>CNN</span></h6><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="python" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="python"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Layer</span> (<span class="cm-builtin">type</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-variable">Output</span> <span class="cm-variable">Shape</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">Param</span> <span class="cm-comment"># &nbsp; </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">=================================================================</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">conv2d_1</span> (<span class="cm-variable">Conv2D</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">25</span>, <span class="cm-number">26</span>, <span class="cm-number">26</span>) &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">250</span> &nbsp; &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">max_pooling2d_1</span> (<span class="cm-variable">MaxPooling2</span> (<span class="cm-keyword">None</span>, <span class="cm-number">12</span>, <span class="cm-number">13</span>, <span class="cm-number">26</span>) &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">conv2d_2</span> (<span class="cm-variable">Conv2D</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">10</span>, <span class="cm-number">11</span>, <span class="cm-number">50</span>) &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">11750</span> &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">max_pooling2d_2</span> (<span class="cm-variable">MaxPooling2</span> (<span class="cm-keyword">None</span>, <span class="cm-number">5</span>, <span class="cm-number">5</span>, <span class="cm-number">50</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">flatten_1</span> (<span class="cm-variable">Flatten</span>) &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">1250</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">dense_5</span> (<span class="cm-variable">Dense</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">100</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">125100</span> &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">dense_6</span> (<span class="cm-variable">Dense</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<span class="cm-keyword">None</span>, <span class="cm-number">10</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">1010</span> &nbsp; &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">=================================================================</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Total</span> <span class="cm-variable">params</span>: <span class="cm-number">138</span>,<span class="cm-number">110</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Trainable</span> <span class="cm-variable">params</span>: <span class="cm-number">138</span>,<span class="cm-number">110</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Non</span><span class="cm-operator">-</span><span class="cm-variable">trainable</span> <span class="cm-variable">params</span>: <span class="cm-number">0</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">_________________________________________________________________</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">1</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">8</span><span class="cm-variable">s</span> <span class="cm-number">785</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.6778</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.8113</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">2</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">734</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.2302</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9349</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">3</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">8</span><span class="cm-variable">s</span> <span class="cm-number">765</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.1562</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9532</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">4</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">8</span><span class="cm-variable">s</span> <span class="cm-number">760</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.1094</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9680</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">5</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">8</span><span class="cm-variable">s</span> <span class="cm-number">843</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0809</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9763</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">6</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">748</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0664</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9810</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">7</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">8</span><span class="cm-variable">s</span> <span class="cm-number">764</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0529</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9832</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">8</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">747</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0370</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9904</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">9</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">687</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0302</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9919</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">10</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">690</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0224</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9940</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">11</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">698</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0177</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9959</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">12</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">690</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0154</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9965</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">13</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">692</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0126</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9962</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">14</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">689</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0130</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9966</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">15</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">691</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0092</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9977</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">16</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">691</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0067</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9986</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">17</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">687</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0069</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9985</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">18</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">691</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0040</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">0.9995</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">19</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">745</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0020</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">1.0000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Epoch</span> <span class="cm-number">20</span><span class="cm-operator">/</span><span class="cm-number">20</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">8</span><span class="cm-variable">s</span> <span class="cm-number">782</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span> <span class="cm-operator">-</span> <span class="cm-variable">loss</span>: <span class="cm-number">0.0014</span> <span class="cm-operator">-</span> <span class="cm-variable">acc</span>: <span class="cm-number">1.0000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">7</span><span class="cm-variable">s</span> <span class="cm-number">657</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Train</span> <span class="cm-variable">CNN</span> <span class="cm-variable">Acc</span>: <span class="cm-number">1.0</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">10000</span><span class="cm-operator">/</span><span class="cm-number">10000</span> [==============================] <span class="cm-operator">-</span> <span class="cm-number">5</span><span class="cm-variable">s</span> <span class="cm-number">526</span><span class="cm-variable">us</span><span class="cm-operator">/</span><span class="cm-variable">step</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Test</span> <span class="cm-variable">CNN</span> <span class="cm-variable">Acc</span>: <span class="cm-number">0.98</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1518px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1518px;"></div></div></div></pre><p>&nbsp;</p></div>
</body>
</html>